@include('admin.layout.bone_header')

<div class="layui-btn-container">
    <button class="layui-btn" data-type="addOlis">添加能源</button>
</div>


<table class="layui-hide" id="think-table" lay-filter="think-table"></table>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
{{--    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>--}}
</script>

<script>

    layui.use('table', function () {
        let table = layui.table;
        UI.getPageTable(table, "{{route('admin.olis.olis')}}", [
            {field: 'oli_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
            , {field: 'oli_title', title: ' 标题'}
            , {field: 'price', title: ' 价格'}
            , {field: 'vip_index_str', title: ' 会员类型',templet:function (d){
                    let status_str = ['不赠送会员','赠送会员']
                    return status_str[d['vip_index']]
                }}
            , {field: 'status', title: ' 上下架',templet:function (d){
                    let status_str = ['上架中','下架中']
                    return status_str[d['status']]
                }}
            ,{fixed: 'right',title:'操作', align:'center', toolbar: '#barDemo'}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event === 'edit'){
                UI.openLayer("{{route('admin.olis.edit')}}?oli_id="+data['oli_id'],980);
            }
            {{--else if(obj.event == 'del'){--}}
            {{--    UI.delete(data['goods_id'],function(res){--}}
            {{--        table.reload('think-table');--}}
            {{--    },"{{route('admin.goods.del')}}");--}}
            {{--}--}}
        });
        let $ = layui.$, active = {
            addOlis:function (){
                UI.openLayer("{{route('admin.olis.add')}}")
            }
        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
